package com.example.demo.service.impl;

import com.example.demo.dao.ResultDao;
import com.example.demo.entity.Result;
import com.example.demo.service.ResultService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;

@Service
public class ResultServiceImpl implements ResultService {
    @Resource
    private ResultDao resultDao;

    @Override
    public Integer addNewResult(Result result) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        result.setCreateTime(dateFormat.format(new Date()));
        //result.setCreateTime(new Date());
        result.setStatus(1);
        Integer rel = resultDao.addNewResult(result);
        return rel;
    }

    @Override
    public Result getResultByUserId(Integer userId) {
        return resultDao.getResultByUserId(userId);
    }
}
